package com.yzr.common.windowscmd;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @description
 * @author: yzr
 * @date: 2021/12/9 16:42
 **/
public class WindowsShellUtil {


    private static final Logger log = LoggerFactory.getLogger(WindowsShellUtil.class);

    /**
     * @param commandParameters 命令参数
     * @return boolean
     */
    public static boolean performTerminalTasks(final String commandParameters) {
        // Process可以控制该子进程的执行或获取该子进程的信息
        Process process = null;
        try {
            process = Runtime.getRuntime().exec(commandParameters);

            process.waitFor();
        } catch (Exception e) {
            log.error("获取执行命令失败：{}", e.getMessage());
        } finally {
            if (null != process) {
                process.destroy();
            }
        }
        return true;
    }
}
